package com.ruoyi.web.controller.construction;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.construction.ConstructionLabel;
import com.ruoyi.system.service.construction.ConstructionLabelService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/construction/conlabel")
public class ConstructionLabelController extends BaseController {

    @Autowired
    private ConstructionLabelService constructionLabelService;




    /**
     * 查询施工队标签列表
     */
//    @PreAuthorize("@ss.hasPermi('construction:conlabel:list')")
    @GetMapping("/conlabel/list/{constructionPicId}")
    public List<ConstructionLabel> list(@PathVariable("constructionPicId") Integer constructionPicId)
    {
//        startPage();
        List<ConstructionLabel> list = constructionLabelService.selectConstructionLabelList(constructionPicId);
        return list;
    }

    /**
     * 导出施工队标签列表
     */
//    @PreAuthorize("@ss.hasPermi('construction:conlabel:export')")
    @Log(title = "施工队标签", businessType = BusinessType.EXPORT)
    @GetMapping("/conlabel/export")
    public AjaxResult export(ConstructionLabel constructionLabel)
    {
//        List<ConstructionLabel> list = constructionLabelService.selectConstructionLabelList(constructionLabel);
//        ExcelUtil<ConstructionLabel> util = new ExcelUtil<ConstructionLabel>(ConstructionLabel.class);
        return null;
    }

    /**
     * 获取施工队标签详细信息
     */
//    @PreAuthorize("@ss.hasPermi('construction:conlabel:query')")
    @GetMapping(value = "/conlabel/{labelId}")
    public AjaxResult getInfo(@PathVariable("labelId") Long labelId)
    {
        return AjaxResult.success(constructionLabelService.selectConstructionLabelById(labelId));
    }

    /**
     * 新增施工队标签
     */
//    @PreAuthorize("@ss.hasPermi('construction:conlabel:add')")
    @Log(title = "施工队标签", businessType = BusinessType.INSERT)
    @PostMapping(value = "/conlabel/add")
    public AjaxResult add(@RequestBody ConstructionLabel constructionLabel)
    {
        Long constructionIdNum = constructionLabel.getConstructionIdNum();
        Integer constructionPicIdNum = constructionLabel.getConstructionPicIdNum();
        constructionLabel.setConstructionId(constructionIdNum);
        constructionLabel.setConstructionPicId(constructionPicIdNum);
        constructionLabel.setModifiedTime(new Date());
        constructionLabel.setDelFlag("0");
        return toAjax(constructionLabelService.insertConstructionLabel(constructionLabel));
    }

    /**
     * 修改施工队标签
     */
//    @PreAuthorize("@ss.hasPermi('construction:conlabel:edit')")
    @Log(title = "施工队标签", businessType = BusinessType.UPDATE)
    @PutMapping(value = "/conlabel/edit")
    public AjaxResult edit(@RequestBody ConstructionLabel constructionLabel)
    {
        return toAjax(constructionLabelService.updateConstructionLabel(constructionLabel));
    }

    /**
     * 删除施工队标签
     */
//    @PreAuthorize("@ss.hasPermi('construction:conlabel:remove')")
    @Log(title = "施工队标签", businessType = BusinessType.DELETE)
    @DeleteMapping("/conlabel/{labelIds}")
    public AjaxResult remove(@PathVariable Long[] labelIds)
    {
        return toAjax(constructionLabelService.deleteConstructionLabelByIds(labelIds));
    }


}
